// 4. col_wise 
// build : g++ -I/usr/include/eigen3 4.col_wise.cpp 
#include <Eigen/Dense>
#include <iostream>
 

int main()
{
    Eigen::MatrixXf m(2,2);
    m << 1,-2,
        -3,4;
    // find the greatest coefficient of every column
    std::cout<< "maximum colwise" << m.colwise().maxCoeff()<<std::endl;
    std::cout<< "minimum colwise" << m.colwise().minCoeff()<<std::endl;

    // from eigen https://eigen.tuxfamily.org/dox/group__TutorialReductionsVisitorsBroadcasting.html
    std::cout << "1-norm(m)     = " << m.cwiseAbs().colwise().sum().maxCoeff()
    << " == "             << m.colwise().lpNorm<1>().maxCoeff() << std::endl;

    std::cout << "infty-norm(m) = " << m.cwiseAbs().rowwise().sum().maxCoeff()
    << " == "             << m.rowwise().lpNorm<1>().maxCoeff() << std::endl;
}